USE 351 - create embeddings for source current records#39
Merged
Conversation
Why these changes are being introduced: The original ergonomics of the CLI command `create-embeddings` was to target a specific ETL run with `--run-id`, optionally limiting by offset and limit. This is essentially all we need for normal day-to-day ETL usage. But there are situations where we might want to create embeddings for a source, and we'd really only want the current records of the source, outside of an ETL context (e.g. new embeddings model or strategy, no need to re-ETL all the records). How this addresses that need: Add `--source` flag to the `create-embeddings` command, which is mutually exclusive with the `--run-id` flag. By using the `--source` flag, it's implying you want to create embeddings for current records from that source. It can still be limited by offset and limit. Side effects of this change: * Ability to run ad-hoc embeddings creation for a source. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-351
Why these changes are being introduced: The transformers library recently had a 5.0 release, https://github.com/huggingface/transformers/releases/tag/v5.0.0. This currently has breaking changes with our current model opensearch-project/opensearch-neural-sparse-encoding-doc-v3-gte. How this addresses that need: Until Opensearch patches the model to work with transformers 5.x, we will pin to transformers<=5.0 which is version 4.57.6 at this time. Confirmed this works both local bare metal and locally built Docker containers. Side effects of this change: * We will want to keep an eye on the model and transformers library compatibility to remove this pin when possible. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-351
5df25bd to
f93e025
Compare
ehanson8
approved these changes
Jan 27, 2026
ehanson8
left a comment
There was a problem hiding this comment.
Works as expected and code looks good, approved!
Comment on lines
+270
to
+273
| if run_id and source: | ||
| raise click.UsageError("Use either '--run-id' or '--source', not both.") | ||
| if not run_id and not source: | ||
| raise click.UsageError( |
There was a problem hiding this comment.
Excellent use of exceptions to force expected usage!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose and background context
This PR allows us to create embeddings for all, or a subset of, current records for a given source. Formerly the CLI command
create-embeddingsonly supported creating embeddings for a particular ETLrun_id.While this likely won't get used much in the day-to-day ETL runs, it'll be quite helpful for out-of-band runs. For example, this functionality is getting used right now to generate embeddings for all sources in Dev1.
Additional updates in this PR:
transformers<5.xafter a major 5.0 release which had breaking changes for our modelHow can a reviewer manually see the effects of these changes?
1- Set Dev1 credentials in terminal
2- Ensure that a model is downloaded (wipe
/tmp/te-modelif desired):3- Create embeddins for current
libguidessource records:--record-limitflag is optional to keep the job smallerThe use of
--sourcetells thecreate-embeddingscommand to retrieve current records for the source versus a single ETL run.Includes new or updated dependencies?
YES
transformers<=5.0Changes expectations for external applications?
NO
What are the relevant tickets?
Code review